<?php
include_once("codelibrary/inc/variables.php");
include_once("session.php");
include_once("codelibrary/inc/functions.php");
include('includes/header.php');

$business_id = $_SESSION['business_id'];

$today_date = date("Y-m-d");
$date_passed = $today_date;
$displayed_day = date("d");
$displayed_month = date("n");
$displayed_year = date("Y");

if(isset($_REQUEST['prev']))
{
        if(isset($_REQUEST['day']) && $_REQUEST['day']!='')
		{
			$displayed_day = $_REQUEST['day'];
		}
		
		if(isset($_REQUEST['month']) && $_REQUEST['month']!='')
		{
			$displayed_month = $_REQUEST['month'];
		}
		
		if(isset($_REQUEST['year']) && $_REQUEST['year']!='')
		{
			$displayed_year = $_REQUEST['year'];
		}
		
    $date_combo_box = date ("Y-m-d", mktime (0,0,0,$displayed_month,$displayed_day,$displayed_year));
    
	$date_passed = AddDay($date_combo_box,-1);
}
if(isset($_REQUEST['next']))
{
    
        if(isset($_REQUEST['day']) && $_REQUEST['day']!='')
		{
			$displayed_day = $_REQUEST['day'];
		}
		
		if(isset($_REQUEST['month']) && $_REQUEST['month']!='')
		{
			$displayed_month = $_REQUEST['month'];
		}
		
		if(isset($_REQUEST['year']) && $_REQUEST['year']!='')
		{
			$displayed_year = $_REQUEST['year'];
		}
    $date_combo_box = date ("Y-m-d", mktime (0,0,0,$displayed_month,$displayed_day,$displayed_year));
    
	$date_passed = AddDay($date_combo_box,1);
}

if(isset($_REQUEST['Go']))
{
   
        if(isset($_REQUEST['day']) && $_REQUEST['day']!='')
		{
			$displayed_day = $_REQUEST['day'];
		}
		
		if(isset($_REQUEST['month']) && $_REQUEST['month']!='')
		{
			$displayed_month = $_REQUEST['month'];
		}
		
		if(isset($_REQUEST['year']) && $_REQUEST['year']!='')
		{
			$displayed_year = $_REQUEST['year'];
		}
		
		$date_passed = date ("Y-m-d", mktime(0, 0, 0, $displayed_month, $displayed_day, $displayed_year));
}

if(isset($_REQUEST['fromcal']))
{
        if(isset($_REQUEST['day']))
		{
			$displayed_day = $_REQUEST['day'];
		}
		else
		{
		    $displayed_day = 1;
		}
		if(isset($_REQUEST['month']) && $_REQUEST['month']!='')
		{
			$displayed_month = $_REQUEST['month'];
		}
		
		if(isset($_REQUEST['year']) && $_REQUEST['year']!='')
		{
			$displayed_year = $_REQUEST['year'];
		}
		
		$date_passed = date ("Y-m-d", mktime(0, 0, 0, $displayed_month, $displayed_day, $displayed_year));
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
</head>

<body>
<?php
include(HC_Controls);
?>
<form name="datefrm" action="sampledatescript.php" method="post">

<br/>
<br/>
<input type="submit" name="prev" value="<<">
<input type="submit" name="next" value=">>">
<?php
datelisting($date_passed);
?>
&nbsp;&nbsp;
<input type="submit" name="Go" value="Go" />
<br /><br />
<?php

$displayed_date_array = explode("-",$date_passed);
$displayed_year = $displayed_date_array[0];
$displayed_month = $displayed_date_array[1];
$displayed_day = $displayed_date_array[2];
$month_desc = date ("M", mktime(0, 0, 0, $displayed_month, $displayed_day, $displayed_year));
$weekday = date("l", mktime(0, 0, 0, $displayed_month, $displayed_day, $displayed_year));
echo $weekday." ".$month_desc." ".$displayed_day.", ".$displayed_year;
?>

</form>
</body>
</html>
